package com.showde.shoppingmall.activity;

import com.showde.shoppingmall.utils.ActivityDispatch;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View.OnClickListener;

public abstract class BaseActivity extends Activity implements OnClickListener {

	private static final String TAG = "BaseActivity";
	public int groupTag;
	Intent intent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getGroupTag();
		initParam();
		initView();
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	private void getGroupTag() {
		intent = getIntent();
		groupTag = intent.getIntExtra(ActivityDispatch.GROUP_TAG, -1);
	}

	/**
	 * 初始化参数
	 */
	protected abstract void initParam();

	/**
	 * 初始化视图
	 */
	protected abstract void initView();

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			return true;
		} else {
			return super.onKeyDown(keyCode, event);
		}
	}

}
